package com.yjxxt.studentInfo;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * 视频单元考核   作业单元考核  考试单元考核  总成绩     性别
 *    20	       47.2	      30	   97.2	     女
 */

public class StudentInfoMapper extends Mapper<LongWritable , Text , Text , Text> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text , Text>.Context context) throws IOException, InterruptedException {
        //拆分数据
        String [] split = value.toString().split("\t");
        // 判断是否为脏数据
        if(split != null && split.length==5){

            String total_grade=split[3];

            // 写出的Key和Value用Text存储，关键字是总成绩，值是这一行的内容
            context.write(new Text(total_grade),new Text(value.toString()));

        }
    }
}
